package DAO.impl.jdbc;

import domain.User;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.SQLException;
import java.util.List;

import org.apache.log4j.Logger;

import DAO.IUserDAO;

public class UserDAO extends JdbcDAO implements IUserDAO {

	private static Logger log = Logger.getLogger(UserDAO.class);
	
	@Override
	public boolean registerUser(User user) {
	
		Connection con = this.GetConnection();
		if (con != null )
		{
			
			String formatsql = "INSERT INTO users (id, userNickName, userPassword, userGender, userAge, userInfo, userStatus) VALUES (?,?,?,?,?,?,?)";
			PreparedStatement execsql;
			try {
				execsql = con.prepareStatement(formatsql);
				execsql.setInt(1, user.getId());
				execsql.setString(2, user.getUserNickName());
				execsql.setString(3, user.getUserPassword());
				execsql.setInt(4, user.getUserGender());
				execsql.setInt(5, user.getUserAge());
				execsql.setString(6, user.getUserInfo());
				execsql.setInt(7, user.getUserStatus());
				execsql.executeUpdate();
				con.close();
				return true;
			} catch (SQLException e) {
				// TODO Auto-generated catch block
				log.error(e.getMessage());
				return false;
			}
		}
		return false;

	}

	@Override
	public User getUser(String userNickName, String userPassword) {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public boolean updateUserData(User user) {
		// TODO Auto-generated method stub
		return false;
	}

	@Override
	public boolean deleteUser(int id) {
		// TODO Auto-generated method stub
		return false;
	}

	@Override
	public User getUser(int id) {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public List<User> getAllUsers() {
		// TODO Auto-generated method stub
		return null;
	}

}
